package net.blf2.mybatisplus.sqlinject;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;

public class UserSelectOneInject extends AbstractMethod {

    @Override
    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {

        String sql = "select * from " + tableInfo.getTableName() +" where " + tableInfo.getKeyColumn() + "= #{id} and sex = #{sex}";
        SqlSource sqlSource =languageDriver.createSqlSource(configuration,sql,Object.class);
        return addSelectMappedStatement(mapperClass, "selectOneBySqlInject", sqlSource, modelClass, tableInfo);
    }
}
